//
//  XQOrderDetailPersonalController.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/9.
//

import UIKit

class XQOrderDetailPersonalController: XQBaseIdentityController {

    override func requestData() {
        let params : [String : String] = [
            "taxes" : self.orderId
        ]
        
        XQHud.showLoading(controller: self)
        XQNetworkManager.shared.postRequest(url: "/figures/workers", parameters: params) {[weak self] response, error in
            guard let srongify = self else {return}
            XQHud.hideLoading(controller: srongify)
            if (response?.object == 0) {
                if let model = XQBaseIdentityModel.deserialize(from: response?.procedure) {
                    
                    if let list = model.whereas {
                        srongify.updateJsonDic(list: list)
                        srongify.dataSource = list
                    }

                }
            }
        }
    }
    
    override func bottomClick() {
        var params : [String : String] = [
            "taxes" : orderId
        ]
        
        if !jsonDic.isEmpty {
            for key in jsonDic.keys {
                params[key] = jsonDic[key]
            }
        }
        
        XQHud.showLoading(controller: self)
        XQNetworkManager.shared.postRequest(url: "/figures/healthcare", parameters: params) {[weak self] response, error in
            guard let srongify = self else {return}
            XQHud.hideLoading(controller: srongify)
            if (response?.object == 0) {
                srongify.navigationController?.popViewController(animated: true)
                srongify.notifyRisk(numberType: "5")
            }else {
                XQHud.showToast(message: response?.patients ?? "Network Connection Error")
            }
        }
    }
}
